[arm64] Emit cmlt/cmle/fcmlt/fcmle for compares against zero#129819
Open
AndyAyersMS wants to merge 1 commit into
Open
[arm64] Emit cmlt/cmle/fcmlt/fcmle for compares against zero#129819AndyAyersMS wants to merge 1 commit into
AndyAyersMS wants to merge 1 commit into
Conversation
Contain a zero vector operand for CompareLessThan/CompareLessThanOrEqual so the JIT emits the 'less than [or equal to] zero' forms instead of materializing zero and swapping operands. Fixes dotnet#64785. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Member
Author
|
@dhartglassMSFT PTAL (I'm just scanning for "old, neglected" arm64 cq issues) |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates ARM64 HWIntrinsic lowering/codegen so AdvSimd.CompareLessThan* and CompareLessThanOrEqual* against a zero vector can be represented with a contained zero operand and emitted using the dedicated “compare vs zero” instruction forms (cmlt, cmle, fcmlt, fcmle) rather than materializing a zero vector and swapping operands.
Changes:
- Add containment support for
CompareLessThan*/CompareLessThanOrEqual*whenop2is a zero vector (excluding unsigned base types). - Teach ARM64 HWIntrinsic codegen to select
cmlt/cmle/fcmlt/fcmlewhen the second operand is a contained zero. - Extend the existing
Runtime_33972JIT regression test with ARM64 codegen-check coverage and runtime validation for representative vector and scalar cases.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/coreclr/jit/lowerarmarch.cpp | Adds containment for zero op2 on less-than / less-than-or-equal AdvSimd intrinsics (signed-only). |
| src/coreclr/jit/hwintrinsiclistarm64.h | Marks the relevant intrinsics as supporting containment / constant-prop to enable the new lowering path. |
| src/coreclr/jit/hwintrinsiccodegenarm64.cpp | Emits cmlt/cmle/fcmlt/fcmle when op2 is a contained zero; otherwise preserves the prior operand-swap emission. |
| src/tests/JIT/Regression/JitBlue/Runtime_33972/Runtime_33972.cs | Adds codegen-check assertions and functional validation for the new zero-compare instruction selection. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contain a zero vector operand for
CompareLessThan/CompareLessThanOrEqualso the JIT emits the "less than [or equal to] zero" instruction forms
(
cmlt,cmle,fcmlt,fcmle) instead of materializing a zero vector andswapping the operands.
Before:
After:
These instructions were defined in the emitter but never selected in real
codegen. This mirrors the existing containment for
CompareGreaterThan/CompareGreaterThanOrEqual/CompareEqual. Unsigned base types are excludedsince the
cmlt/cmle"with zero" forms are signed-only.Codegen-check coverage is added to the existing
Runtime_33972test for thevector and scalar int32/int64/float/double cases.
Fixes #64785.
Note
This pull request was generated with the assistance of GitHub Copilot.